
local function SScaleX( size )
	return size * ( ScrW() / 1440 )
end

local function SScaleY( size )
	return size * ( ScrH() / 900 )
end

local hud_bg 		= Color( 95, 95, 95, 150 )
local hud_fg		= Color( 20, 20, 20, 255 )
local hud_tint		= Color( 255, 255, 255, 255 )

local gameStatus 	= "none"
local timeLeft		= "none"
local teamName		= "none"
local seekScore		= 0
local hideScore		= 0

local wep 			= nil

local teamTable = {}
	teamTable.texture 		= draw.NoTexture()
	teamTable.color 		= hud_bg
	teamTable.x				= SScaleX( 30 )
	teamTable.y				= SScaleY( 0 )
	teamTable.w				= SScaleX( 170 )
	teamTable.h				= SScaleY( 30 )

local gamestateTable 		= {}
	gamestateTable.texture 	= draw.NoTexture()
	gamestateTable.color 	= hud_bg
	gamestateTable.x		= SScaleX( 580 )
	gamestateTable.y		= SScaleY( 0 )
	gamestateTable.w		= SScaleX( 280 )
	gamestateTable.h		= SScaleY( 30 )
	
local timeTable = {}
	timeTable.texture 		= draw.NoTexture()
	timeTable.color 		= hud_bg
	timeTable.x				= SScaleX( 1240 )
	timeTable.y				= SScaleY( 0 )
	timeTable.w				= SScaleX( 170 )
	timeTable.h				= SScaleY( 30 )
	
local healthTable = {}
	healthTable.texture 	= draw.NoTexture()
	healthTable.color 		= hud_bg
	healthTable.x			= SScaleX( 0 )
	healthTable.y			= SScaleY( 600 )
	healthTable.w			= SScaleX( 20 )
	healthTable.h			= SScaleY( 300 )

local healthTableOvr = {}
	healthTableOvr.texture 	= draw.NoTexture()
	healthTableOvr.color 	= table.Copy( hud_fg )
	healthTableOvr.x		= SScaleX( 0 )
	healthTableOvr.y		= SScaleY( 600 )
	healthTableOvr.w		= SScaleX( 20 )
	healthTableOvr.h		= SScaleY( 300 )

local ammoTable = {}
	ammoTable.texture 		= draw.NoTexture()
	ammoTable.color 		= hud_bg
	ammoTable.x				= SScaleX( 1420 )
	ammoTable.y				= SScaleY( 600 )
	ammoTable.w				= SScaleX( 20 )
	ammoTable.h				= SScaleY( 300 )

local ammoTableOvr = {}
	ammoTableOvr.texture 	= draw.NoTexture()
	ammoTableOvr.color 		= table.Copy( hud_fg )
	ammoTableOvr.x			= SScaleX( 1420 )
	ammoTableOvr.y			= SScaleY( 600 )
	ammoTableOvr.w			= SScaleX( 20 )
	ammoTableOvr.h			= SScaleY( 300 )
	
local blindedTable = {}
	blindedTable.texture 	= draw.NoTexture()
	blindedTable.color 		= Color( 0, 0, 0, 255 )
	blindedTable.x			= SScaleX( 0 )
	blindedTable.y			= SScaleY( 0 )
	blindedTable.w			= SScaleX( 1440 )
	blindedTable.h			= SScaleY( 900 )
	
	
function hudThink()
	
	local ply = LocalPlayer()
	
	local teamID = ply:Team()
	
	gameStatus 	= GetStatusString( HNS_GAMESTATUS )
	
	timeLeft = string.ToMinutesSeconds( HNS_TIMELEFT )
	
	teamName 	= GetTeamName( teamID )
	hud_tint 	= team.GetColor( teamID )
	
	seekScore 	= team.GetScore( TEAM_SEEK )
	hideScore 	= team.GetScore( TEAM_HIDE )
	
	wep	= ply:GetActiveWeapon()
	local ammo 		= 0 
	
	if wep && wep:IsValid() then
		ammo = wep:Clip1()
		if ammo != -1 then
			ammoTableOvr.y		= SScaleY( 900 ) - ( ( SScaleY( 300 ) / 100 ) * ammo )
		else
			wep = nil
		end
	end
	
	if ammo == 100 then
		ammoTableOvr.color = hud_tint
	else
		ammoTableOvr.color = hud_fg
	end
	
	local health 	= ply:Health()
	
	healthTableOvr.y = SScaleY( 900 ) - ( ( SScaleY( 300 ) / 100 ) * health )
	
	local ratio = health / 100
	local red = 255 * ( 1 - ratio )
	local green	= 255 * ratio
	
	healthTableOvr.color.r = red
	healthTableOvr.color.g = green
	healthTableOvr.color.b = 0

end
hook.Add( "Think", "hudThink", hudThink )

local screenCenterX = SScaleX( 720 )
local screenCenterY = SScaleY( 450 )

function hudDraw()

	draw.TexturedQuad( teamTable )
	draw.SimpleText( teamName, "ScoreboardSub", SScaleX( 115 ), SScaleY( 15 ), hud_tint, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )

	draw.TexturedQuad( gamestateTable )
	draw.SimpleText( gameStatus, "ScoreboardSub", screenCenterX, SScaleY( 15 ), hud_tint, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
	
	draw.TexturedQuad( timeTable )
	draw.SimpleText( timeLeft, "ScoreboardSub", SScaleX( 1325 ), SScaleY( 15 ), hud_tint, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
	
	draw.TexturedQuad( healthTable )
	draw.TexturedQuad( healthTableOvr )	
	
	if wep then
		draw.TexturedQuad( ammoTable )
		draw.TexturedQuad( ammoTableOvr )	
	end
	
	if LocalPlayer():Team() == TEAM_SEEK && HNS_TIMELEFT > HNSConfig["round_time"] - 10 then
		draw.TexturedQuad( blindedTable )
	end
	
end
hook.Add( "HUDPaint", "hudDraw", hudDraw )

function GM:HUDShouldDraw( name )
	if 	name == "CHudHealth" or 
		name == "CHudSuitPower" or 
		name == "CHudBattery" or 
		name == "CHudSecondaryAmmo" or 
		name == "CHudAmmo" or 
		name == "CHudWeaponSelection" then
		
		return false
	end
	return true
end 